<template>
  <div class="loginContainer">
    <div class="formContainer">
      <el-form :model="registerForm" :rules="rules" ref="registerForm">
        <div class="title">颐养中心系统</div>
        <el-form-item prop="username">
          <el-input class="inp" @keyup.13.native="login()" clearable v-model="registerForm.username" placeholder="请输入用户名" style="width: 400px;"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input class="inp" clearable v-model="registerForm.password" show-password placeholder="请输入密码" style="width: 400px;" @keyup.13.native="login()"></el-input>
        </el-form-item>

        <div class="btnContainer">
          <el-button type="primary" round @click="register()">提交</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
// import { register } from "../utils/payM";
import  axios from '@/utils/request'
export default {
  name: 'register',
  data() {
    return {
      registerForm: {
        username: '',
        password: '',

      },
      token: '',
      rules: {
        username: [
          {
            required: true,
            message: '请输入用户名',
            trigger: 'blur'
          }
        ],
        password: [
          {
            required: true,
            message: '请输入密码',
            trigger: 'blur'
          }
        ],

      }
    }
  },
  methods: {
    register() {
      if (!this.registerForm.username) {
        this.$message.error('未输入用户名');
        return;
      }
      if (!this.registerForm.password) {
        this.$message.error('未输入密码');
        return;
      }


      axios.post("/login",this.registerForm).then((res) => {
        console.log("提交------完成")
        console.log("提交注册接口", res);
        if (res.data.code == 200) {
          this.$router.push('/login')
        }
        this.$message.success(res.data.code == 200);
      })
    }
  }
}
</script>

<style scoped>
.loginContainer {
  display: flex;
  width: 100vw;
  height: 100vh;
  /* background-color: #00FFFF; */
  justify-content: center;
  align-items: center;
}


.formContainer {
  width: 400px;
  height: 240px;
  border: 1px solid #ebebeb;
  border-radius: 3px;
  transition: .2s;
  padding: 20px;
  box-shadow: 2px 2px 10px #06C;
}

.title {
  font-size: 30px;
  margin-bottom: 20px;
  text-align: center;

}


.inp {
  margin-bottom: 10px;
}


.btnContainer {
  display: flex;
  justify-content: center;
}
</style>
